#!/bin/bash

img_mvn="maven:3.3.3-jdk-8"
m2_cache=~/.m2                              # the local maven cache dir
proj_home=$PWD                              # the project root dir

if which mvn ; then
    echo "use local maven"
    mvn clean package -U
else
    echo "use docker maven"
    docker run --rm \
        -v $m2_cache:/root/.m2 \
        -v $proj_home:/usr/src/mymaven \
        -w /usr/src/mymaven $img_mvn mvn install
fi

mv $proj_home/target/leedemo-*-SNAPSHOT.jar $proj_home/target/leedemo.jar
